package com.ruyue.csinstall;

import com.ruyue.csinstall.command.Command;
import com.ruyue.csinstall.command.MacroCommand;
import com.ruyue.csinstall.command.RequestInvoker;
import com.ruyue.csinstall.command.impl.*;
import com.ruyue.csinstall.model.CsPro;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.*;

/**
 * @author xiawl
 * @create 2017/7/23 14:18.
 */
public class CSIns {
    private static final Log log = LogFactory.getLog(CSIns.class);

    public static void main(String[] args) {
        CsPro cspro = new CsPro();
        Command
                command1 = new UnZipCommand(cspro),//解压程序包
                command2 = new InitCommand(cspro),//初始化
                command3 = new CpCommand(cspro),//拷贝证书类文件
                command4 = new MergePropertiesCommand(cspro),//合并*.properties
                command5 = new MergeConvertXmlCommand(cspro),//合并*_convert.xml
                command6 = new MergeFiletransferXmlCommand(cspro);//合并filetransfer-config.xml

        List<Command> commands = new ArrayList<Command>();
        commands.add(command1);
        commands.add(command2);
        commands.add(command3);
        commands.add(command4);
        commands.add(command5);
        commands.add(command6);
        Command macroCommand = new MacroCommand(commands);

        RequestInvoker invoker = new RequestInvoker();
        invoker.setCommand(macroCommand);

        log.info("开始通讯机升级...");
        invoker.startExecuteCommand();
        log.info("完成通讯机升级...");
    }
}